import {
    Member
} from './member.model'
const member = new Member()
Page({
    data: {
        count: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad() {
        let that = this
        that._loadData()
    },

    /**
     * 获取所有数据
     */
    _loadData() {
        let that = this
        // 是否授权
        wx.getSetting({
            success: (res) => {
                if (res.authSetting['scope.userInfo']) {
                    that.getMemberData()
                }
            }
        })
    },

    /**
     * 获取积分
     */
    getMemberData() {
        let that = this
        member.getMemberData().then((res) => {
            that.setData({
                count: res.data.member
            })
        }).then(() => {
            wx.stopPullDownRefresh()
            wx.hideNavigationBarLoading()
            wx.hideLoading()
        })
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {
        wx.showLoading({
            title: '正在加载数据',
        })
        let that = this
        wx.showNavigationBarLoading()
        that._loadData()
    },

})